package reflect;

/**
 * JDK5之后推出了一个新的特性:可变长参数
 */
public class ArgsDemo {
    public static void main(String[] args) {
        test();
        test("a");
        test("a","b");
        test("a","b","c");
        test("a","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c");
    }
    /*
        变长参数要求必须是一个方法中最后一个参数
     */
    public static void test(String... arg){//arg相当于一个数组
        System.out.println(arg.length);
    }

//    编译后的样子:
//    public static void main(String[] args) {
//        test(new String[]{});
//        test(new String[]{"a"});
//        test(new String[]{"a","b"});
//        test(new String[]{"a","b","c"});
//        test(new String[]{"a","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c","b","c"});
//    }
//    public static void test(String[] arg){
//        System.out.println(arg.length);
//    }
}




